import './commands';
import '@cypress/code-coverage/support';

const istanbul = require('istanbul-lib-coverage');
const map = istanbul.createCoverageMap({});

Cypress.on('window:before:unload', e => {
    const coverage = e.currentTarget.__coverage__;
    if (coverage) {
        map.merge(coverage);
    }
});

Cypress.on('uncaught:exception', e => {
    return !e.message.includes('ResizeObserver loop limit exceeded');
});

after(() => {
    cy.window().then(win => {
        const coverage = win.__coverage__;
        if (coverage) {
            map.merge(coverage);
        }
        cy.writeFile('.nyc_output/out.json', JSON.stringify(map));
    });
});
